package com.jwenfeng.library.pulltorefresh.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.jwenfeng.library.R;

public class CategoryHeadRefreshView extends FrameLayout implements HeadView {
    private AnimationDrawable mAnimationDrawable;

    @SuppressLint("NewApi")
    public CategoryHeadRefreshView(@NonNull Context context) {
        super(context);

        View view = View.inflate(context, R.layout.layout_category_header, null);
        addView(view);

        ImageView image = view.findViewById(R.id.image_cate);
        image.setImageDrawable(context.getDrawable(R.drawable.load_anim));
        mAnimationDrawable = (AnimationDrawable) image.getDrawable();
    }

    @Override
    public void begin() {

    }

    @Override
    public void progress(float progress, float all) {
    }

    @Override
    public void finishing(float progress, float all) {
        mAnimationDrawable.stop();
    }

    @Override
    public void loading() {
        mAnimationDrawable.start();
    }

    @Override
    public void normal() {

    }

    @Override
    public View getView() {
        return this;
    }
}
